package sg.edu.nus.iss.phoenix.authenticate.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import sg.edu.nus.iss.phoenix.authenticate.dao.RoleDao;
import sg.edu.nus.iss.phoenix.authenticate.entity.Role;
import sg.edu.nus.iss.phoenix.authenticate.entity.User;
import sg.edu.nus.iss.phoenix.core.dao.DAOFactoryImpl;
import sg.edu.nus.iss.phoenix.core.exceptions.NotFoundException;
/**
 * RoleService Class provides the Access to User DAO
 * @author Pum Khat Doe (A0092694R)
 * @version 1.0 2012/9/20
*/ 
public class RoleService {
	DAOFactoryImpl factory;

	RoleDao rdao;

	public RoleService() {
		super();
		factory = new DAOFactoryImpl();
		rdao = factory.getRoleDAO();

	}
  /**
	 * findAllRoles-method. 
	 * This will get all the roles from database and return Roles in list object.
	 * @return Role list
	 * @throws SQLException If database exception occurred	 
	 */
	public List<Role> findAllRoles() {
		List<Role> currentList = new ArrayList<Role>();

		try {
			currentList = rdao.loadAll();

		} catch (SQLException e) {
			e.printStackTrace();
		}

		return currentList;

	}
}
